package com.vallis.asfc.controller;


import com.vallis.asfc.entity.AsfcMatch;
import com.vallis.asfc.service.AsfcMatchService;
import com.vallis.asfc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.xml.crypto.Data;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author vallis
 * @since 2020-08-10
 */
@RestController
@RequestMapping("/asfc-match")
@CrossOrigin
public class AsfcMatchController {


    @Autowired
    private AsfcMatchService asfcMatchService;

    @PutMapping("addAsfcMatch")
    public Result addAsfcMatch(@RequestBody AsfcMatch asfcMatch) {
        System.out.println(asfcMatch);
        boolean save = asfcMatchService.save(asfcMatch);

        return new Result(200, "成功", save);
    }

    @GetMapping("getMatch")
    public Result getMatch() {
        List<AsfcMatch> list = asfcMatchService.list();
        System.out.println("查询所有赛事");
        System.out.println(list.size());
        return new Result(200, "成功", list);
    }

    @PutMapping("updateMatch")
    public Result updateMatch(@RequestBody AsfcMatch asfcMatch) {
        boolean b = asfcMatchService.saveOrUpdate(asfcMatch);

        return new Result(200, "成功", b);
    }

    @PutMapping("deleteMatch")
    public Result deleteMatch(Long id) {
        return new Result(200, "成功", asfcMatchService.removeById(id));
    }
}
